home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 078 (1990-06)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 078 (1990-06)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / TrackSalve / TrackSalve / Source / ts.i < prev    next >
Text File  |  1990-06-17  |  7KB  |  170 lines

  1. *
  2. *  ts.i     -   Copyright 1990 D.W.Reisig
  3. *
  4. *   #     date     by    Comment
  5. *  -- --------- ----- ---------------------
  6. *   0 29-Oct-89     DWR   Created for Tracksalve
  7. *   1 10-Apr-90     DWR   TrackSalve 1.3, more switches
  8. *
  9.  
  10.         INCLUDE "exec/types.i"
  11.         INCLUDE "exec/memory.i"
  12.         INCLUDE "exec/semaphores.i"
  13.         INCLUDE "devices/trackdisk.i"
  14.         INCLUDE "hardware/cia.i"
  15.         INCLUDE "hardware/blit.i"
  16.  
  17. TD_VERSION1_2    equ    33
  18. TD_VERSION1_3    equ    34
  19. PUBCLR        equ    (MEMF_PUBLIC+MEMF_CLEAR)
  20.  
  21. *--    Secondary result codes
  22.  
  23. E_CMDLINE    equ    -41            Some syntax error in the commandline is met
  24. E_ALLOCMEM    equ    -42            No success with AllocMem()
  25. E_INTUITION    equ    -43            No success with OpenLibrary
  26. E_RTAG        equ    -44            No success with FindResident()
  27. E_TD_VERSION    equ    -45            Not supported version of Trackdisk
  28. E_CATCHTD    equ    -46            TD's pc is not at the expected position
  29.  
  30. *--    The findable TSHook structure.  We put it in the semaphore list.  Donot change!
  31.  
  32.           STRUCTURE TSH,SS_SIZE        Struct SignalSemaphore
  33.         APTR    TSH_TSControl        Pointer to data and patch
  34.         ULONG    TSH_Version        Value to check own compatibility
  35.         LABEL    TSH_SIZE
  36.  
  37. *--    The UnitData structure contains data of interest for a particular Trackdisk unit task.
  38.  
  39.           STRUCTURE TSBN,bn_SIZEOF        Extended blit node, data area available for blitter fuctions
  40.         WORD    TSBN_Pad        Long alignment
  41.         APTR    TSBN_P0            Some pointers
  42.         APTR    TSBN_P1        
  43.         APTR    TSBN_P2        
  44.         APTR    TSBN_P3
  45.         APTR    TSBN_Unit        Td's unit pointer
  46.         UWORD    TSBN_C0            Control 0
  47.         UWORD    TSBN_C1            Control 1
  48.         LABEL    TSBN_SIZE
  49.  
  50.           STRUCTURE UD,0
  51.         STRUCT    UD_TDReq,IOTD_SIZE    Used for OpenDevice() of all units
  52.         APTR    UD_TSControl        Pointer to shared data area
  53.         APTR    UD_ReturnTD        Value of PC when caught in ROM
  54.         APTR    UD_Userdata        Original value of tc_UserData
  55.         APTR    UD_CopySect        Copy routine if IO buffers non chip
  56.         UBYTE    UD_Cmd0            Field used for preparation of commands
  57.         UBYTE    UD_Cmd1            Command pattern to the trackdisk task
  58.         UWORD    UD_SavedL        Bitflags of saved sector labels (good are cleared)
  59.         UWORD    UD_SavedD        Bitflags of saved data blocks (good are cleared)
  60.         UWORD    UD_Update        Counter to determine when to update and auto motor off
  61.         STRUCT    UD_BlitNode,TSBN_SIZE    We use a static blitnode, saves us repeated inits.
  62.         LABEL    UD_SIZE
  63.  
  64. *--    The global control structure.  It contains data concerning shared items between all TD-tasks.
  65.  
  66.           STRUCTURE TSC,0
  67.         APTR    TSC_TSHook        Semaphore to set for drastic TSC accesses
  68.         STRUCT    TSC_UnitData,NUMUNITS*4 Pointers to UnitData structures
  69.         STRUCT    TSC_UDAlloc,NUMUNITS*UD_SIZE  The UnitData structures itself
  70.         APTR    TSC_TDTag        Pointer to Trackdisk romtag in ROM
  71.         ULONG    TSC_TDCodeSize        Size of Trackdisk code
  72.         APTR    TSC_TSTag        Pointer to Trackdisk romtag in RAM
  73.         APTR    TSC_TSCode        Pointer to extension code
  74.         ULONG    TSC_TSCodeSize        Size of extension code
  75.         APTR    TSC_Buffer        Pointer to shared buffer
  76.         UBYTE    TSC_InUse        Bit pattern of units which use the control structure
  77.         UBYTE    TSC_Salve        Bit pattern of units which use the buffer for salvage
  78.         UBYTE    TSC_Verify        Bit pattern of units which use the buffer for verify
  79.         UBYTE    TSC_AvailUnits        Bit pattern of existing Trackdisk units
  80.         STRUCT    TSC_OwnBuffer,SS_SIZE    Semaphore for usage of the buffer
  81.         APTR    TSC_IntuBase        IntuitionBase for building requesters
  82.         ULONG    TSC_Size        Size of control structure + extension code + TD code, one allocation
  83.         LABEL    TSC_SIZE
  84.  
  85. *--    Bits of the UD_Cmd1, UD_Cmd0 and TDU_pad
  86.  
  87.         BITDEF    ,VERIFY0,0
  88.         BITDEF    ,VERIFY1,1
  89.         BITDEF    ,READONLY,2
  90.         BITDEF    ,NOCLICK,3
  91.         BITDEF    ,SALVE,4
  92.         BITDEF    ,UPDATE,5
  93.         BITDEF    ,RAM,6
  94.         BITDEF    ,TERM,7
  95.  
  96. FUNCTIONS    EQU    F_RAM+F_VERIFY1+F_VERIFY0+F_SALVE+F_NOCLICK+F_READONLY
  97.  
  98.  
  99. *--    Some NON-Public members of the Trackdisk unit and device structure
  100.  
  101. TDU_NTracks    equ    $36            Word. Number of tracks on this disk
  102. TDU_Flags    equ    $40            Byte. Some statistics about the inserted disk
  103. TDU_CiabPb    equ    $41            Byte. Memory to prepare commands to hardware
  104. TDU_Retries    equ    $42            Byte. Number of performed retries
  105. TDU_UnitNr    equ    $43            Byte. Identification number
  106. TDU_IOReq    equ    $44            Long. IORequest currently processed
  107. TDU_IOSector    equ    $49            Byte. Sector currently I/O'ed
  108. TDU_XTrack    equ    $4a            Word. Desired track
  109. TDU_PTrack    equ    $4c            Word. Present track
  110. TDU_DiskBuf    equ    $4e            Long. Buffer used for disk i/o
  111. TDU_UnitBuf    equ    $52            Long. Pointer to buffer allocated by the TD unit
  112. TDU_TCB        equ    $12e            Begin of task control block
  113.  
  114. TDD_SysBase    equ    $34            Long. Pointer to ExecBase
  115. TDD_GfxBase    equ    $38            Long. Pointer to GfxBase
  116.  
  117. *--
  118.  
  119. _ciaa        equ    $BFE001
  120. _ciab        equ    $BFD000
  121.             ;09876543210
  122. BADTRACKBITS    equ    %11111111111        One bit for every sector/label
  123. DISKFORMAT    equ    -1            First field in the sector address
  124. SYNC        equ    $4489            Uniq pattern to recognise the beginning of data
  125. SYNCSYNC    equ    $44894489        idem
  126. GAPSIZE        equ    1660            Size of first written non-data part of a track
  127. SPT        equ    11            Sectors per track
  128. UPDATECOUNT    equ    10            Ten times .5 seconds before auto update
  129.  
  130. *--    Structures used by Trackdisk or its patch
  131.  
  132.           STRUCTURE HE,0            Sector Header structure
  133.         BYTE    HE_Format        Contens: DISKFORMAT
  134.         BYTE    HE_TrkNo        Tracknumber the formatter thought the head was on during format
  135.         BYTE    HE_SecNo        Sectornumber from 0 to 10
  136.         BYTE    HE_ToGap        Number of sectors until gap
  137.         LABEL    HE_SIZE            Warning: Maybe subtracted from the stackpointer
  138.  
  139.           STRUCTURE SE,0            MFM encoded sector
  140.         ULONG    SE_Start        Contens: $AAAAAAAA
  141.         ULONG    SE_Sync            Contens: SYNCSYNC
  142.         STRUCT    SE_Header,HE_SIZE*2    HE_ structure
  143.         STRUCT    SE_Label,TD_LABELSIZE*2
  144.         STRUCT    SE_SumL,4*2        Checksum over SE_Header and SE_Label
  145.         STRUCT    SE_SumD,4*2        Checksum over SE_Data
  146.         STRUCT    SE_Data,TD_SECTOR*2
  147.         LABEL    SE_SIZE
  148.  
  149. SSIZE        equ    SE_SIZE-SE_Label
  150. LSIZE        equ    SE_SumL-SE_Label
  151. DSIZE        equ    SE_SIZE-SE_SumD
  152.  
  153.           STRUCTURE TB,0            Picture of trackbuffer as TD uses
  154.         WORD    TB_TrkNo        Tracknumber of track in buffer, -1 if none or bad
  155.         BYTE    TB_ChgFlag        Bit 0. 1 means that the buffer must be written to disk before...
  156.         BYTE    TB_FirstSec        First sector present at position TB_Data
  157.         STRUCT    TB_Gap,GAPSIZE        MFM-zeros. Written first to clear the area behind the last write.
  158.         STRUCT    TB_Data,SPT*SE_SIZE    SPT SE_ structures
  159.         LABEL    TB_SIZE
  160.  
  161.           STRUCTURE SB,0            Salvebuffer
  162.         STRUCT    SB_Header,HE_SIZE    Just some storage to ease access to the bytes of the header structure
  163.         APTR    SB_Begin        Begin of data (EA of SB_Data)
  164.         APTR    SB_End            End of sync search area
  165.         WORD    SB_CorrectTrk        Number of matching tracknumbers during buffer scan
  166.         WORD    SB_WrongTrk        Number of non-matching tracknumbers during buffer scan
  167.         STRUCT    SB_Data,2*SPT*SE_SIZE+GAPSIZE    Buffer in which data is read from disk
  168.         LABEL    SB_SIZE
  169.  
  170.